package com.mrd.gtimp.base.entity;

import com.mrd.annotation.validation.InDeclarationRequiredGroup;
import com.mrd.annotation.validation.MRDRequired;
import com.mrd.annotation.validation.OutDeclarationRequiredGroup;
import com.mrd.gtimp.base.service.CompanyBiz;

import org.hibernate.annotations.GenericGenerator;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
 * <p> application name: gtimp <p> copyright: Copyright@2012 明睿达科技有限公司
 *
 * @author qiul
 * @author luob
 * @author qiul
 * @author luob
 * @author qiul
 * @author luob
 * @author qiul
 * @author luob
 * @author qiul
 * @author luob
 * @author qiul
 * @author luob
 * @author qiul
 * @author luob
 * @author qiul
 * @author luob
 * @author qiul
 * @author luob
 * @author qiul
 * @author luob
 * @author qiul
 * @author luob
 * @author qiul
 * @author luob
 */
/**
 * @author qiul
 */
/**
 * @author luob
 */

/**
 * @author luob
 */
@Entity
@Table(name = "T_SYS_COMPANY")
public class Company extends CompanyBiz implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(generator = "paymentableGenerator")
    @GenericGenerator(name = "paymentableGenerator", strategy = "uuid")
    @Column(name = "COM_ID")
    @MRDRequired(groups = {InDeclarationRequiredGroup.class, OutDeclarationRequiredGroup.class}, name = "报关行")
    private String id;

    @Column(name = "COM_NAME")
    private String name;

    @Column(name = "COM_ADDRESS")
    private String address;

    @Column(name = "COM_CONTACTOR")
    private String contactor;

    @Column(name = "COM_PHONE")
    private String phone;

    @Column(name = "COM_MOBILE")
    private String mobile;

    @Column(name = "COM_TYPE")
    private String type;

    @Column(name = "COM_FAX")
    private String fax;

    @Column(name = "COM_VALIDATE")
    private String validate;

    @Column(name = "COM_REMARKS")
    private String remarks;

    @Column(name = "COM_ISABLED")
    private String isabled;

    @Column(name = "COM_STATE")
    private String state;

    @Column(name = "CREATOR")
    private String creator;

    @Column(name = "CTIME")
    @Temporal(TemporalType.TIMESTAMP)
    private Date ctime;

    @Column(name = "MODIFIER")
    private String modifier;

    @Column(name = "MTIME")
    @Temporal(TemporalType.TIMESTAMP)
    private Date mtime;

    @Column(name = "PORT")
    private String port;

    @Column(name = "PORT_CODE")
    private String port_code;

    @Column(name = "COM_CUSTOMS_CODE")
    private String com_customs_code;

    /**
     * 统一社会信用代码
     */
    @Column(name = "COM_CODE")
    private String com_code;

    @OneToMany
    @JoinTable(name = "T_SYS_COM_DEPT", joinColumns = @JoinColumn(name = "COM_ID"),
            inverseJoinColumns = @JoinColumn(name = "DEPT_ID"))
    private Set<Dept> depts;

    @OneToMany(targetEntity = ComMaterial.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    // @Fetch(FetchMode.JOIN)
    @JoinColumn(name = "COM_ID", updatable = false)
    private Set<ComMaterial> materials;

    public void setIsParent(String isParent) {
        this.isParent = isParent;
    }

    @Transient
    private String isParent;
    @Column(name = "SHORT_NAME")
    private String SHORT_NAME;

    /**
     * 供应商开通的业务类型
     */
    @ManyToMany
    @JoinTable(name = "T_BIZ_SUP_TYPE", joinColumns = @JoinColumn(name = "SUP_ID",
            updatable = false), inverseJoinColumns = @JoinColumn(name = "TYPE_ID"))
    private List<SystemValue> supTypes;

    /**
     * 是否开通数据接口，0-不开通，1-开通
     */
    @Column(name = "IS_SIGN_WS")
    private String isSignWS;

    public String getIsSignWS() {
        return isSignWS;
    }

    public void setIsSignWS(String isSignWS) {
        this.isSignWS = isSignWS;
    }

    public Company() {
        super();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getContactor() {
        return contactor;
    }

    public void setContactor(String contactor) {
        this.contactor = contactor;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getFax() {
        return fax;
    }

    public void setFax(String fax) {
        this.fax = fax;
    }

    public String getValidate() {
        return validate;
    }

    public void setValidate(String validate) {
        this.validate = validate;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public String getIsabled() {
        return isabled;
    }

    public void setIsabled(String isabled) {
        this.isabled = isabled;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getCreator() {
        return creator;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }

    public Date getCtime() {
        return ctime;
    }

    public void setCtime(Date ctime) {
        this.ctime = ctime;
    }

    public String getModifier() {
        return modifier;
    }

    public void setModifier(String modifier) {
        this.modifier = modifier;
    }

    public Date getMtime() {
        return mtime;
    }

    public void setMtime(Date mtime) {
        this.mtime = mtime;
    }

    public Set<ComMaterial> getMaterials() {
        return materials;
    }

    public void setMaterials(Set<ComMaterial> materials) {
        this.materials = materials;
    }

    public String getIsParent() {
        return isParent;
    }

    public void setIsParent(boolean isParent) {
        this.isParent = String.valueOf(isParent);
    }

    public Set<Dept> getDepts() {
        return depts;
    }

    public void setDepts(Set<Dept> depts) {
        this.depts = depts;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @Override
    public String toString() {
        return "{id:" + id + ",name:" + name + ",isParent:" + isParent + "}";
    }

    public String getSHORT_NAME() {
        return SHORT_NAME;
    }

    public void setSHORT_NAME(String sHORT_NAME) {
        SHORT_NAME = sHORT_NAME ;
    }

    public String getPort() {
        return port;
    }

    public void setPort(String port) {
        this.port = port;
    }

    public String getPort_code() {
        return port_code;
    }

    public void setPort_code(String port_code) {
        this.port_code = port_code;
    }

    public String getCom_customs_code() {
        return com_customs_code;
    }

    public void setCom_customs_code(String com_customs_code) {
        this.com_customs_code = com_customs_code;
    }

    public String getCom_code() {
        return com_code;
    }

    public void setCom_code(String com_code) {
        this.com_code = com_code;
    }
}
